IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[painting]') AND TYPE in (N'U'))
BEGIN
CREATE TABLE painting
(
    painting_id INT IDENTITY(1,1) NOT NULL,
    title NVARCHAR(100) NULL,
    painting_number NVARCHAR(100) NULL,
    description NVARCHAR(Max) NULL,
    image_url NVARCHAR(Max) NULL,
    tags NVARCHAR(Max) NULL,
    authorships NVARCHAR(Max) NULL,
    subjects NVARCHAR(Max) NULL,
    
    create_date DATETIME DEFAULT(GETDATE()),
    update_date DATETIME,
	CONSTRAINT PK_painting_id PRIMARY KEY CLUSTERED (painting_id)
) 
END
GO

IF NOT EXISTS(SELECT 1 FROM syscolumns WHERE [Name]='hand_enable' AND Id=(SELECT Id FROM sysobjects WHERE [Name]='painting'))
    ALTER TABLE painting ADD hand_enable bit NULL
GO

IF NOT EXISTS(SELECT 1 FROM syscolumns WHERE [Name]='printer_enable' AND Id=(SELECT Id FROM sysobjects WHERE [Name]='painting'))
    ALTER TABLE painting ADD printer_enable bit NULL
GO

IF NOT EXISTS(SELECT 1 FROM syscolumns WHERE [Name]='frames' AND Id=(SELECT Id FROM sysobjects WHERE [Name]='painting'))
    ALTER TABLE painting ADD frames int NULL default(0)
GO